﻿$(function()
    {
    	$('#destinations').change(function()
    			{
    				var $mainCat = $('#destinations :selected').attr('data-value');
    				if(!$mainCat){
    					$mainCat = $('#destinations').val();
    					}
    			// .call ajax
    				$("#subdestination").empty();
    			$.ajax
    				(
    					{
    						url:"tournow.html",
    						type:'POST',
                            
    						data:{id : destinations + $mainCat},
                            dataType: "html",
    						success:function(results)
    						{
    							options = $(results);
    							if(options.length > 1){
    								$("#subdestination").removeAttr("disabled");
    							} else {
    								if(!$("#subdestination").is(':disabled')){
    									$("#subdestination").attr("disabled", "disabled");
    								}
    							}
    								$("#subdestination").append(results);
    								$("#subdestination").selectBox('destroy');
    								$("#subdestination").selectBox();
    						}
    					}
    				);
    			});
    }); 